<?php

namespace App\Http\Requests\Logic\Position;

use App\Models\User;
use Illuminate\Foundation\Http\FormRequest;

class StoreResource extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
		/**
		 * @var User $user
		 */
		$user = $this->user();
		$company = $user->getCompany();
		if ($company) {
			$this->offsetSet('company_id', $company->id);
			return true;
		}
		return false;
    }

	/**
	 * 定义表单验证规则
	 *
	 * Date: 18/04/2018
	 * @author George
	 * @return array
	 */
    public function rules()
    {
        return [
        	'company_id' => 'nullable|integer',
        	'department_id' => 'required|integer',
        	'name' => 'required',
			'wage' => 'required'
        ];
    }
}
